﻿using System;
using S7.Net;

namespace S7PlcDataCollector.Models
{
    /// <summary>
    /// PLC实体
    /// </summary>
    public class S7PlcEntity
    {
        public int Rid { get; set; }
        public int Type { get; set; }
        public string Ip { get; set; }
        public int Port { get; set; }
        public short Rack { get; set; }
        public short Slot { get; set; }

        public CpuType TypeEnum => Enum.IsDefined(typeof(CpuType), Type)
            ? (CpuType) Type
            : CpuType.S7200;

        public S7PlcEntity CloneEntity()
        {
            return new S7PlcEntity()
            {
                Rid = Rid,
                Type = Type,
                Ip = Ip,
                Port = Port,
                Rack = Rack,
                Slot = Slot
            };
        }
    }
}
